/*点击事件*/
$(document).ready(function(){
	$(".web_chat_tab_chat").click(function(){
		$(".web_chat_tab_chat").css("background-position"," -185px -96px");//变绿色
		$(".web_chat_tab_friends").css("background-position","-220px -96px");
	});
	$(".web_chat_tab_friends").click(function(){
		$(".web_chat_tab_chat").css("background-position","-150px -96px");
		$(".web_chat_tab_friends").css("background-position","-304px -246px");//变绿色
	});
        /*var windowHeight=$(window).height();
        var InitHeight=windowHeight-45;
        Initials.height(InitHeight);
        var LiHeight=InitHeight/28;
        Initials.find('li').height(LiHeight);*/
});
function initials() {//公众号排序
    var SortList=$(".chat_item");
    var SortBox=$("#J_NavChatScrollBody");
    SortList.sort(asc_sort).appendTo('#J_NavChatScrollBody');//按首字母排序
    function asc_sort(a, b) {
        return makePy($(b).find('.nickname').text().charAt(0))[0].toUpperCase() < makePy($(a).find('.nickname').text().charAt(0))[0].toUpperCase() ? 1 : -1;
    }

    var initials = [];
    var num=0;
    SortList.each(function(i) {
        var initial = makePy($(this).find('.nickname').text().charAt(0))[0].toUpperCase();
        if(initial>='A'&&initial<='Z'){
            if (initials.indexOf(initial) === -1)
                initials.push(initial);
        }else{
            num++;
        }
        
    });

    $.each(initials, function(index, value) {//添加首字母标签
        SortBox.append('<h4 class="sort_letter contact_title" style="color:#fff;margin:0px;padding:0px 20px;background-color:#26292e;" id="'+ value +'">' + value + '</h4>');
    });
    if(num!=0){SortBox.append('<h4 class="sort_letter contact_title" id="default" style="color:#fff;margin:0px;padding:0px 20px;background-color:#26292e;">#</h4>');}

    for (var i =0;i<SortList.length;i++) {//插入到对应的首字母后面
        var letter=makePy(SortList.eq(i).find('.nickname').text().charAt(0))[0].toUpperCase();
			if(letter>='A' && letter<='Z') {
				$('#' + letter).after(SortList.eq(i));
			} else {
				$('#default').after(SortList.eq(i));
			}
    };
}